
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0800
 * @Author : WangRuoyu 
 * @Date : 2023/9/17 16:47
 */

#include "iostream"

using namespace std;

int main() {
    int m, n, x;
    scanf("%d %d %d", &m, &n, &x);
    int a[m];
    int b[n];
    for (int i = 0; i < m; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b[i]);
    }

    int l = 0;
    int r = n - 1;

    while (a[l] + b[r] != x) {
        if (a[l] + b[r] < x) {
            l++;
        } else if (a[l] + b[r] > x) {
            r--;
        }
    }

    printf("%d %d", l, r);

    return 0;
}